#include "../stdafx.h"
#include "Material.h"

CMaterial::CMaterial()
{
	GLfloat ambient[] = {1.0, 1.0, 1.0, 1.0};
	GLfloat specular[] = {1.0, 1.0, 1.0, 1.0};
	for (int i = 0; i < 4; i++)
	{
		m_ambient[i] = ambient[i];
		m_specular[i] = specular[i];
	}
	m_shininess = 90;
}

CMaterial::~CMaterial()
{

}

void CMaterial::SetMaterialParas(float ambient[], float specular[], float shininess)
{
	if (ambient)
	{
		for (int i = 0; i < 4; i++)
			m_ambient[i] = ambient[i];
	}
	glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, m_ambient);
	if (specular)
	{
		for (int i = 0; i < 4; i++)
			m_specular[i] = specular[i];
	}
	glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, m_specular);
	if (shininess >= 0)
		m_shininess = shininess;
	glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, &m_shininess);
}